package com.wish.group05.system.api.factory;

import com.wish.group05.common.core.web.domain.AjaxResult;
import com.wish.group05.system.api.RemoteDictDataService;
import feign.hystrix.FallbackFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Component;

/**
 * 字典降级处理
 *
 * @author wish
 */
@Component
public class RemoteDictDataFallbackFactory implements FallbackFactory<RemoteDictDataService> {
    private static final Logger log = LoggerFactory.getLogger(RemoteDictDataFallbackFactory.class);
    @Override
    public RemoteDictDataService create(Throwable throwable) {
        log.error("字典服务调用失败:{}", throwable.getMessage());
        return new RemoteDictDataService() {
            @Override
            public AjaxResult getDictDataList(String dictType) {
                return AjaxResult.error("字典数据调用失败："+ throwable.getMessage());
            }
        };
    }
}
